from multiprocessing import Pool, Lock
import time
from random import random
from multiprocessing import Queue

"""

gevent

"""

def task(task_name):
    print('begin', task_name)
    start = time.time()

    time.sleep(random() * 2)
    end = time.time()
    print('end', end - start)


"""
pool = Pool(max)
pool.apply()        阻塞
pool.apply_async() 非阻塞

pool.close()
pool.join()

"""

q = Queue(5)

q.put('A')
q.put('A')
q.put('A')
q.put('A')


lock = Lock()



if __name__ == '__main__':
    globals()

    lock.acquire()
    pool = Pool(5)
    # for i in random(5):
    for i in range(5):
        pass
